﻿using System;
using System.Windows.Forms;
using Autodesk.Revit.DB;
using RevitInteractiveUtility.ExternalEventManager;

namespace SampleAndTest.ExternalEventManager.SingleFromDemo
{
	internal class SingleFormRequestA : IRequest
	{
		public SingleFormRequestA(int iRequestId)
		{
			this.m_iRequestId = iRequestId;
		}

		public int RequestId
		{
			get
			{
				return this.m_iRequestId;
			}
		}

		public void DoRequest(object parameters = null)
		{
			ModelLineData modelLineData = parameters as ModelLineData;
			Transaction transaction = new Transaction(modelLineData.Doc);
			try
			{
				transaction.Start("SingleFormTransaction");
				MessageBox.Show(this.m_iRequestId.ToString() + "事务开启成功！");
				SketchPlane sketchPlane = SketchPlane.Create(modelLineData.Doc, modelLineData.GeoPlane);
				modelLineData.Doc.Create.NewModelCurve(modelLineData.GeoCv, sketchPlane);
				transaction.Commit();
			}
			catch
			{
				MessageBox.Show(this.m_iRequestId.ToString() + "事务开启失败！");
				transaction.RollBack();
			}
		}

		private int m_iRequestId;
	}
}
